package com.cqs.learning.spring.cloud.producer.web;

import com.cqs.learning.spring.cloud.producer.service.ServiceDemo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * Created by li on 20-2-29.
 */
@RequestMapping()
@RestController
@Log4j2
public class ProductController {

    @Autowired
    private ServiceDemo iFuseService;

    @RequestMapping(value = "/cnt")
    public String cnt() {
        int count = iFuseService.cnt();
        log.info("product01 cnt:" + count);
        //TODO 验证负载策略
        try {
            TimeUnit.MILLISECONDS.sleep(300);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "product01 cnt:" + count;
    }

    @RequestMapping(value = "/cnt2")
    public String cnt2() {
        int count = iFuseService.cnt2();
        log.info("product01 cnt:" + count);
        return "product01 cnt:" + count;
    }
}
